﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QiHe.UserManage
{
    public partial class User_Depts_List : Form
        
    {
        DataSet DeptList;
        DataSet DeptList3;
        DataSet UserList;
        DataSet UserDeptList;
        public User_Depts_List()
        {
            InitializeComponent();
            MedEQ.Service1 sop = new MedEQ.Service1();
            DeptList = sop.HSP_Department_List(DataTemp.HSPID);
            DeptList3 = sop.HSP_Department_List(DataTemp.HSPID);

            skinComboBox1.DataSource = DeptList.Tables[0];
            skinComboBox1.DisplayMember = "Name";
            skinComboBox1.ValueMember = "DeptNumber";
           

            skinComboBox2.DataSource = DeptList3.Tables[0];
            skinComboBox2.DisplayMember = "Name";
            skinComboBox2.ValueMember = "DeptNumber";
         


        }

        private void User_Depts_List_Load(object sender, EventArgs e)
        {

        }

 

    

        private void skinComboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            MedEQ.Service1 sop = new MedEQ.Service1();
            UserList = sop.User_List_By_Dept(skinComboBox1.SelectedValue.ToString());

            listBox1.DataSource = UserList.Tables[0];
            listBox1.DisplayMember = "ChineseName";
            listBox1.ValueMember = "ID";
        }

 

        private void listBox1_DoubleClick(object sender, EventArgs e)
        {
            MedEQ.Service1 sop = new MedEQ.Service1();
            UserDeptList = sop.Dept_List_By_User(listBox1.SelectedValue.ToString());

            listBox2.DataSource = UserDeptList.Tables[0];
            listBox2.DisplayMember = "Name";
            listBox2.ValueMember = "DeptNumber";
        }

        private void skinComboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            DataSet DeptList2;
            MedEQ.Service1 sop = new MedEQ.Service1();
            DeptList2 = sop.Department_List_By_PID(skinComboBox2.SelectedValue.ToString());

            listBox3.DataSource = DeptList2.Tables[0];
            listBox3.DisplayMember = "Name";
            listBox3.ValueMember = "DeptNumber";
        }

    



        private void listBox3_SelectedIndexChanged(object sender, EventArgs e)
        {
            DataSet DeptList2;
            MedEQ.Service1 sop = new MedEQ.Service1();
            DeptList2 = sop.Department_List_By_PID(listBox3.SelectedValue.ToString());

            listBox4.DataSource = DeptList2.Tables[0];
            listBox4.DisplayMember = "Name";
            listBox4.ValueMember = "DeptNumber";
        }

        private void skinButton2_Click(object sender, EventArgs e)
        {
            MedEQ.Service1 sop = new MedEQ.Service1();
            sop.Add_User_Dept(listBox1.SelectedValue.ToString(),listBox3.SelectedValue.ToString());


           
            UserDeptList = sop.Dept_List_By_User(listBox1.SelectedValue.ToString());

            listBox2.DataSource = UserDeptList.Tables[0];
            listBox2.DisplayMember = "Name";
            listBox2.ValueMember = "DeptNumber";

        }

        private void skinButton3_Click(object sender, EventArgs e)
        {
            MedEQ.Service1 sop = new MedEQ.Service1();
            sop.Add_User_Dept(listBox1.SelectedValue.ToString(), listBox4.SelectedValue.ToString());



            UserDeptList = sop.Dept_List_By_User(listBox1.SelectedValue.ToString());

            listBox2.DataSource = UserDeptList.Tables[0];
            listBox2.DisplayMember = "Name";
            listBox2.ValueMember = "DeptNumber";
        }

        private void skinButton4_Click(object sender, EventArgs e)
        {
            MedEQ.Service1 sop = new MedEQ.Service1();
            sop.DEL_User_Dept(listBox1.SelectedValue.ToString(), listBox2.SelectedValue.ToString());



            UserDeptList = sop.Dept_List_By_User(listBox1.SelectedValue.ToString());

            listBox2.DataSource = UserDeptList.Tables[0];
            listBox2.DisplayMember = "Name";
            listBox2.ValueMember = "DeptNumber";
        }

      
    }
}
